package com.xinsilu.hospital.controller;


import com.xinsilu.common.Result;
import com.xinsilu.hospital.entity.DepartmentTable;
import com.xinsilu.hospital.entity.DoctorTable;
import com.xinsilu.hospital.entity.DrugTable;
import com.xinsilu.hospital.service.IDoctorTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ym
 * @since 2021-09-22
 */
@RestController
@RequestMapping("/api/hospital/doctorTable")
public class DoctorTableController {
    @Autowired
    private IDoctorTableService iDoctorTableService;

    @RequestMapping("/yssousuo")
    public Object sousuo(String type,String departmentname){
        DoctorTable doctorTable=new DoctorTable();
        doctorTable.setType(type);
        DepartmentTable departmentTable=new DepartmentTable();

        departmentTable.setName(departmentname);
        doctorTable.setDepartmentTable(departmentTable);
        System.out.println(doctorTable.getType()+"---"+doctorTable.getDepartmentTable().getName());
        List<DoctorTable> list = iDoctorTableService.yssousuo(doctorTable);
        return Result.ok(list);

    }

    @RequestMapping("/yssuo")
    public Object yssuo() {
        List<DoctorTable> list = iDoctorTableService.yssuo();
        return Result.ok(list);

    }
    @RequestMapping("/getDocterTable")
    public  Object getDocterTable(){
        List<DoctorTable> list = iDoctorTableService.getDocterTable();
        return Result.ok(list);
    }

    @RequestMapping("/addDoctor")
    public Object addDoctor(DoctorTable doctorTable){

            boolean count = iDoctorTableService.save(doctorTable);
            if (count) {
                return Result.ok("新增成功");
            }
            return Result.ok("异常");
    }
    @RequestMapping("/updateDocker")
    public Object updateDocker(DoctorTable doctorTable) {
        boolean b = iDoctorTableService.updateById(doctorTable);
        if (b) {
            return Result.ok("修改成功");
        }
        return Result.ok("修改失败");
    }
}
